<?php
namespace app\work\controller;
use app\common\controller\TyCheck;
use app\work\logic\BaseLogic;
use think\Controller;

/**
 * 基础控制器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/10/29
 * Time: 15:20
 */
class Base extends Controller {

    use TyCheck;

    public function __construct() {
        parent::__construct();
        $this->b_logic = new BaseLogic();
    }

    /**
     * 获取用户信息
     * @return \think\response\Json
     */
    public function ajax_get_user(){
        $params = input();
        $r = $this->check_user_token($params);
        if($r['code'] != 1){
            return json($r);
        }

        //检查用户规则
        $r = $this->b_logic->check_user_rule();
        if($r['code'] != 1){
            return json($r);
        }
        $u_detail = $r['data']['detail'];

        $user_info = [];
        $user_info['department'] = $u_detail['department'];

        $data['user_info'] = $user_info;
        return json($this->b_logic->get_response(1,'OK',$data));
    }
}
